﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace smartphone.App_Code{
    //Chua cac thong tin cau hinh cho Esmart nham cache gia tri tu web.config giup tang toc do
    //tranh phai lien tuc doc thong tin tu web.config
    public static class ESmartConfig
    {
        //cache connection string
        private static string dbConnectionString;
        //cache data providername
        private static string dbProviderName;
        //luu so luong san pham moi trang
        private readonly static int productsPerPage;
        //do dai mo ta
        private readonly static int productDescriptionLength;
        //luu ten site
        private readonly static string siteName;
        //so ngay de 1 gio hang het hang
        static ESmartConfig()
        {
            dbConnectionString = ConfigurationManager.ConnectionStrings["EsmartConnection"].ConnectionString;
            dbProviderName = ConfigurationManager.ConnectionStrings["EsmartConnection"].ProviderName;
            productsPerPage = System.Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);
            productDescriptionLength = System.Int32.Parse(ConfigurationManager.AppSettings["ProductDescriptionLength"]);
            siteName = ConfigurationManager.AppSettings["SiteName"];
        }

        public static string DbConnectionString
        {
            get
            {
                return dbConnectionString;
            }
        }

        public static string DbProviderName
        {
            get
            {
                return dbProviderName;
            }
        }

        //tra ve mailserver trong appseting
        public static string MailServer
        {
            get
            {
                return ConfigurationManager.AppSettings["MailServer"];
            }
        }

        // tra ve email username
        public static string MailUsername
        {
            get
            {
                return ConfigurationManager.AppSettings["MailUsername"];
            }
        }

        // tra ve email password
        public static string MailPassword
        {
            get
            {
                return ConfigurationManager.AppSettings["MailPassword"];
            }
        }

        // tra ve email 
        public static string MailFrom
        {
            get
            {
                return ConfigurationManager.AppSettings["MailFrom"];
            }
        }

        // Send error log emails?
        public static bool EnableErrorLogEmail
        {
            get
            {
                return bool.Parse(ConfigurationManager.AppSettings
                ["EnableErrorLogEmail"]);
            }
        }

        // tra ve dia chi mail nhan cac error reporst
        public static string ErrorLogEmail
        {
            get
            {
                return ConfigurationManager.AppSettings["ErrorLogEmail"];
            }
        }

        //tra ve so luong san pham moi trang
        public static int ProductsPerPage
        {
            get
            {
                return System.Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);
            }
        }

        //tra ve ten site
        public static string SiteName
        {
            get
            {
                return ConfigurationManager.AppSettings["SiteName"];
            }
        }

        //tra ve do dai cua mo ta ngan gon
        public static int ProductDescriptionLength
        {
            get
            {
                return System.Int32.Parse(ConfigurationManager.AppSettings["ProductDescriptionLength"]);
            }
        }

        //so ngay de 1 gio hang duoc tao het han
        public static int CartPersistDays
        {
            get
            {
                return System.Int32.Parse(ConfigurationManager.AppSettings["CartPersistDays"]);
            }
        }

        public static string PaypalUrl
        {
            get
            {
                return ConfigurationManager.AppSettings["PaypalUrl"];
            }
        }
        // lay tai khoan email cua Paypal
        public static string PaypalEmail
        {
            get
            {
                return ConfigurationManager.AppSettings["PaypalEmail"];
            }
        }
        // don vi tien te
        public static string PaypalCurrency
        {
            get
            {
                return ConfigurationManager.AppSettings["PaypalCurrency"];
            }
        }
        // duong link bao giao dich thanh cong
        public static string PaypalReturnUrl
        {
            get
            {
                return ConfigurationManager.AppSettings["PaypalReturnUrl"];
            }
        }
        // link huy giao dich
        public static string PaypalCancelUrl
        {
            get
            {
                return ConfigurationManager.AppSettings["PaypalCancelUrl"];
            }
        }

    }
}